package com.codes.controller;

import com.codes.core.common.result.Result;
import com.codes.service.TemplateRefSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description 
 * @Date 2020/7/4 9:56
 * @Created  peanut
 */

@RestController
@Slf4j
@Api("模板word 接口")
@RequestMapping("/tpl")
public class TemplateRefCtr {

    @Autowired
    private TemplateRefSV templateRefSV;

    /****
     * @param map 根据案件 id  获取 模板列表
     * @Description   获取tpl list
     * @return com.codes.core.common.result.Result
     * @Date 2020/7/4 10:06
     * @Created by peanut
     */
    @GetMapping("/list")
    @ApiOperation("获取模板list")
    public Result getList(@RequestParam Map<String,Object> map){

        Integer caseId = MapUtils.getInteger(map,"caseId");
        if(null == caseId){
            caseId = 1;
        }
        List<Map<String,Object>>  list = templateRefSV.getList(map);
        if( list.size() > 0){
            return Result.success(list);
        }

        return Result.failed("列表获取异常");
    }


}